class MHashMap{
    final static double Loodfactor = 0.75;
    static class Node{
        int k;
        int val;
        Node next;

        public Node(int k, int val) {
            this.k = k;
            this.val = val;
        }
    }
   Node[] array ;
    int size;

    public MHashMap() {
        array = new Node[10];
    }
    public  void put(int key, int val){
        int index = key % array.length;
        //遍历index下标的key,看是否存在key,如果存在则更新val;
       Node cur = array[index];
        while(cur != null){
            if(key == cur.val){
                cur.val = val;
                return;
            }
            cur = cur.next;
        }
        Node node = new Node(key,val);
        node.next = array[index];
        array[index] = node;
        size++;
        if(doLoodfactor()>Loodfactor){

        }
    }
    public double doLoodfactor(){
        return size*1.0/ array.length;
    }
    public void resize(){
       Node[] newarray = new Node[2* array.length];
        for (int i = 0; i < array.length ; i++) {
            Node cur = array[i];
            while(cur != null){
                int newIndex = cur.k% newarray.length;
                Node node = new Node(cur.k, cur.val);
                node.next = newarray[newIndex];
                newarray[newIndex] = node;
                cur = cur.next;
            }
        }
        array = newarray;
    }
    public int get(int key){
        int index = key % array.length;
        //遍历index下标的key,看是否存在key,如果存在则更新val;
     Node cur = array[index];
        while(cur != null){
            if(cur.k == key){
                return cur.val;
            }
            cur = cur.next;
        }
        return -1;
    }
}
public class hstest {
    public static void main(String[] args) {
     MHashMap hashMap = new MHashMap();
     hashMap.put(1,2);
     hashMap.put(6,2);
     hashMap.put(5,2);
     hashMap.put(1,3);
        System.out.println(hashMap.get(1));
    }

}
